//
//  YFBasicViewController.swift
//  微博
//
//  Created by 余仿 on 16/4/9.
//  Copyright © 2016年 YF. All rights reserved.
//

import UIKit

class YFBasicViewController: UINavigationController,UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationBar.setBackgroundImage(UIImage(named: "tabBarBackground"), forBarMetrics: .Default)

        self.interactivePopGestureRecognizer?.delegate = self
        
    }

    override func pushViewController(viewController: UIViewController, animated: Bool) {

        //TODO:此处有疑问待解决,如果将判断语句放在push操作下面,进入的第一个子控制器不会隐藏底部tabBar
        if self.childViewControllers.count > 0{

            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: "返回", target: self, action: "pop")

//            viewController.hidesBottomBarWhenPushed = true
        }

        super.pushViewController(viewController, animated: true)

    }

    func pop(){

        self.popViewControllerAnimated(true)
        
    }

    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {

        if childViewControllers.count == 1{
            return false
        }
        return true

    }
}
